﻿//------------------------------------------------------------------------------
// System Name:    Customer Service Platform
// Component:      CIS Domestic
// Created By:     Parker Zhou(parkerz@wicresoft.com)
// Created Date:   2011-2-12
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace ASBCC.Business.CIS
{
    /// <summary>
    /// CustomerCount bussiness helper
    /// </summary>
    public static class CustomerCountHelper
    {
        /// <summary>
        /// get CustomerCount Infomation , all : level = -1
        /// </summary>
        /// <param name="connStr"></param>
        /// <returns></returns>
        public static DataTable GetCustomerCountInfo(string connStr , int level)
        {
            if (string.IsNullOrEmpty(connStr))
                return null;
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "sp_PCAT_Customer_Statistics";
                cmd.Parameters.Add("@Level", SqlDbType.Int);
                cmd.Parameters["@Level"].Direction = ParameterDirection.Input;
                cmd.Parameters["@Level"].Value = level;
                SqlDataAdapter adpter = new SqlDataAdapter(cmd);
                DataTable dataTable = new DataTable();
                try
                {
                    adpter.Fill(dataTable);
                    return dataTable;
                }
                catch
                {
                    return null;
                }
                
            }
        }
    }
}
